//
//  WKSetViewController.m
//  ourToken
//
//  Created by wakeup on 2018/5/31.
//  Copyright © 2018年 ourtoken. All rights reserved.
//

#import "WKSetViewController.h"
#import "WKBaseHeader.h"

@interface WKSetViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataArray;

@end

@implementation WKSetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationView];
    [self layoutUI];
    self.view.backgroundColor = [UIColor whiteColor];
    self.dataArray = @[@"多语言",@"货币单位"];
}

- (void)setNavigationView {
    [super setNavigationView];
    self.navigationView.topTitleLabel.text = @"系统设置";
}

- (void)layoutUI {
    [self.view addSubview:self.tableView];
}

#pragma mark - UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SetCell"];
    cell.textLabel.text = self.dataArray[indexPath.row];
    cell.textLabel.font = AppManager.tableTextFont;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        WKLanguageViewController *language = [[WKLanguageViewController alloc] init];
        [self.navigationController pushViewController:language animated:YES];
    }
    else if (indexPath.row == 1) {
        WKMonetaryUnitViewController *monetaryUnit = [[WKMonetaryUnitViewController alloc] init];
        [self.navigationController pushViewController:monetaryUnit animated:YES];
    }
}

#pragma mark - 懒加载
- (UITableView *)tableView {
    if (_tableView == nil) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, AppManager.navigationHeight, AppManager.width, AppManager.height-AppManager.navigationHeight) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [[UIView alloc] init];
        _tableView.backgroundColor = AppManager.tableBackColor;
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, AppManager.width, 10)];
    }
    return _tableView;
}

@end
